<%--
  Created by IntelliJ IDEA.
  User: Alex
  Date: 5/1/11
  Time: 9:17 PM
  To change this template use File | Settings | File Templates.
--%>

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="<g:resource dir='css' file='filmring.css' />"/>
        <g:javascript library="jquery" plugin="jquery" />
        <script type="text/javascript" src="<g:resource dir='js' file='twitter.js'/>"></script>
        <script type="text/javascript" src="<g:resource dir='js' file='ratings.js'/>"></script>
        <script type="text/javascript">
            $().ready(function(){
                queryTwitter("${movie.title.encodeAsURL()}");
                preloadimages();
                $(".rating").each(function(index){
                    registerRatingsListeners2(index,($(".rating input")[index]).value,${session.user},"#"+$(this).attr('id'));
                  //  $(this).append("Registered");
                });/*
                registerRatingsListeners("#${topRatings.get(0).movie.id}", ${topRatings.get(0).rating}, ${session.user});
                $("#${topRatings.get(0).movie.id}").append("Registered");
                <g:each in="${topRatings}">
                //each top
                registerRatingsListeners("#${'top/'+it.movie.id}", ${it.rating}, ${session.user});
                $("#${'top/'+it.movie.id}").append("Registered");
                </g:each>
                alert("top registered");
                <g:each in="${newRatrings}">
                //each new
                registerRatingsListeners("#${'release/'+it.movie.id}", ${it.rating}, ${session.user});
                $("#${'release/'+it.movie.id}").append("Registered");
                </g:each>
                alert("new releases registered");*/
            });
        </script>
        <title>Film Ring: ${movie.title}</title>
    </head>
    <body>
        <g:render template="/templates/topbar" />
        <div class="clear"></div>
        <g:render template="/templates/sidebar" model="${['user':user]}"/>
        <div class="container">
            <g:render template="/templates/featuredmovie" model="${[movie:movie,rating:topRatings.get(0)]}"/>
            <g:render template="/templates/twitterfeed" model="${[query:movie.title]}" />
            <div class="clear"></div>
            <div id="newReleaseList">
                <h3>New Releases</h3>
                <g:render template="/templates/movielist" model="${[ratings:newRatings, id:'release']}"/>
            </div>
            <div id="topMovieList">
                <h3>Top Movies</h3>
                <g:render template="/templates/movielist" model="${[ratings:topRatings, id:'top']}"/>
            </div>
        </div>
    </body>
</html>